#include <gtest/gtest.h>

// GreenCode 测试顶层模块
class GreenCodeTestTop {

};

class GreenCodeTestSuite : public ::testing::Test {

public:
    static int g_argc;
    static char** g_argv;

    static void SetUpTestCase() {
        std::cout << "GreenCodeTestSuite SetUpTestCase" << std::endl;
    }

    static void TearDownTestCase() {
        std::cout << "GreenCodeTestSuite TearDownTestCase" << std::endl;
    }

    static void SetUp() override {
        std::cout << "GreenCodeTestSuite SetUp" << std::endl;
    }

    static void TearDown() override {
        std::cout << "GreenCodeTestSuite TearDown" << std::endl;
    }
};

int GreenCodeTest::g_argc = 0;
char** GreenCodeTest::g_argv = nullptr;

// GreenCode测试夹具类
class GreenCodeTest : public ::testing::Test {

protected:
    void SetUp() override {
        //std::cout << "GreenCodeTestSuite SetUp" << std::endl;
    }

    void TearDown() override {
        //std::cout << "GreenCodeTestSuite TearDown" << std::endl;
    }
};

TEST_F(GreenCodeTest, GreenCode_Smoke_Test) {
   // the smoke test for greencode isg
};

// GoogleTest主函数
int main(int argc, char** argv) {
    //处理自定义的命令行参数
    std::string test_filter;
    for (int i = 1; i < argc; ++i) {
        std::string arg = argv[i];
        if (arg == "--test" || arg == "-t") {
            if (i+ 1 < argc) {
                std::string test_name = argv[++i];
                 if(test_name == "smoke") {
                     test_filter = "GreenCodeTest.GreenCode_Smoke_Test";
                 } else {
                    std::cout << "未知的测试名称 ： " << test_name << std::endl;
                    std::cout << "可用测试用例名称 ： " << std::endl;
                    return 1;
                 }
            }
        } else {
            std::cout << " --test 参数需要指定测试用例名称 " << std::endl;
            return 1;
        } 
    } else if (arg == "--help" || arg == "-h") {
            std::cout << " Green Code测试程序使用方法 " << std::endl;
            std::cout << " --test " << std::endl;
            std::cout << " --test " << std::endl;
            std::cout << " --test " << std::endl;
            std::cout << " --test " << std::endl;
            std::cout << std::endl;
            std::cout << " --test " << std::endl;
            return 0
    }

    //将 argc 和 argv 存储到静态成员变量
    GreenCodeTestSuite::g_argc = argc;
    GreenCodeTestSuite::g_argv = argv;

    std::cout <<  the argc is <<argc<<"\n"<<" the argv is "<<argv << "\n" <<std::endl;

    // 初始化 Google Test
    ::testing::InitGoogleTest(&argc, argv);

    // 设置测试过滤器
    if (!test_filter.empty()) {
        ::testing::GTEST_FLAG(filter) = test_filter;
    }

    return RUN_ALL_TESTS();

}
